/**
 * 获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS”
 * @export
 * @returns currentdate
 */

export default function computeTime(key) {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    var year = date.getFullYear();
    var Hours = date.getHours();
    var Minutes = date.getMinutes();
    var Seconds = date.getSeconds();
    var currentdate = ''
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    if (Hours >= 0 && Hours <= 9) {
        Hours = '0' + Hours
    }
    if (Minutes >= 0 && Minutes <= 9) {
        Minutes = '0' + Minutes
    }
    if (Seconds >= 0 && Seconds <= 9) {
        Seconds = '0' + Seconds
    }
   
    
    switch (key) {
        case 'time':
            currentdate = year + seperator1 + month + seperator1 + strDate
                + " " + Hours + seperator2 + Minutes + seperator2 + Seconds;
            return currentdate;
        case 'date':
            currentdate = year + seperator1 + month + seperator1 + strDate;
            return currentdate;
        default:
            break;
    }
    // return {
    //     getNowFormatTime: function () {
    //         var seperator1 = "-";
    //         var seperator2 = ":";
    //         var month = date.getMonth() + 1;
    //         var strDate = date.getDate();
    //         var Hours = date.getHours();
    //         var Minutes = date.getMinutes();
    //         var Seconds = date.getSeconds();
    //         if (month >= 1 && month <= 9) {
    //             month = "0" + month;
    //         }
    //         if (strDate >= 0 && strDate <= 9) {
    //             strDate = "0" + strDate;
    //         }
    //         if (Hours >= 0 && Hours <= 9) {
    //             Hours = '0' + Hours
    //         }
    //         if (Minutes >= 0 && Minutes <= 9) {
    //             Minutes = '0' + Minutes
    //         }
    //         if (Seconds >= 0 && Seconds <= 9) {
    //             Seconds = '0' + Seconds
    //         }
    //         var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
    //             + " " + Hours + seperator2 + Minutes + seperator2 + Seconds;
    //         return currentdate;
    //     },
    //     // 获取当前时间，格式YYYY-MM-DD
    //     getNowFormatDate: function () {
    //         var date = this.newDate;
    //         var seperator1 = "-";
    //         var year = date.getFullYear();
    //         var month = date.getMonth() + 1;
    //         var strDate = date.getDate();
    //         if (month >= 1 && month <= 9) {
    //             month = "0" + month;
    //         }
    //         if (strDate >= 0 && strDate <= 9) {
    //             strDate = "0" + strDate;
    //         }
    //         var currentdate = year + seperator1 + month + seperator1 + strDate;
    //         return currentdate;
    //     }

    // }
}

// export default function getNowFormatDate() {
//     var date = new Date();
//     var seperator1 = "-";
//     var seperator2 = ":";
//     var month = date.getMonth() + 1;
//     var strDate = date.getDate();
//     var Hours = date.getHours();
//     var Minutes = date.getMinutes();
//     var Seconds = date.getSeconds();
//     if (month >= 1 && month <= 9) {
//         month = "0" + month;
//     }
//     if (strDate >= 0 && strDate <= 9) {
//         strDate = "0" + strDate;
//     }
//     if (Hours >= 0 && Hours <= 9) {
//         Hours = '0' + Hours
//     }
//     if (Minutes >= 0 && Minutes <= 9) {
//         Minutes = '0' + Minutes
//     }
//     if (Seconds >= 0 && Seconds <= 9) {
//         Seconds = '0' + Seconds
//     }
//     var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
//         + " " + Hours + seperator2 + Minutes + seperator2 + Seconds;
//     return currentdate;
// }
//获取当前时间，格式YYYY-MM-DD
// function getNowFormatDate() {
//     var date = new Date();
//     var seperator1 = "-";
//     var year = date.getFullYear();
//     var month = date.getMonth() + 1;
//     var strDate = date.getDate();
//     if (month >= 1 && month <= 9) {
//         month = "0" + month;
//     }
//     if (strDate >= 0 && strDate <= 9) {
//         strDate = "0" + strDate;
//     }
//     var currentdate = year + seperator1 + month + seperator1 + strDate;
//     return currentdate;
// }